﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bussiness;
using Entities;
using NUnit.Framework;

namespace TestApplication
{
    [TestFixture]
    public class TestWithdrawMoney
    {
        /// <summary>
        /// Test case 1
        /// </summary>
        [Test]
        public void TestWithdraw_AccountNull_WithdrawFail()
        {
            ATMSystemBussiness target = new ATMSystemBussiness(); 
            float amount = 10000F; 
            CheckingAccount checkAccount = null; 
            bool isPrintRecept = true; 
            bool expected = false; 
            bool actual;
            actual = target.WithdrawMoney(amount, checkAccount, isPrintRecept);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        /// Test case 2
        /// </summary>
        [Test]
        public void TestWithdraw_AmountLessThanZero_WithdrawFail()
        {
            ATMSystemBussiness target = new ATMSystemBussiness();
            float amount = -1F;
            CheckingAccount checkAccount = new CheckingAccount()
                                        {
                                            AccountID = new Guid("5734527e-b09c-4c5a-ab43-240d1d16f469"),
                                            CardID =  new Guid("5734527e-b09c-4c5a-ab43-240d1d16f469"),
                                            Balance = 10000,
                                            DayLimit = 10000,
                                        };
            bool isPrintRecept = true;
            bool expected = false;
            bool actual;
            actual = target.WithdrawMoney(amount, checkAccount, isPrintRecept);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        /// Test case 3
        /// </summary>
        [Test]
        public void TestWithdraw_AmountLessIsZero_WithdrawFail()
        {
            ATMSystemBussiness target = new ATMSystemBussiness();
            float amount = -1F;
            CheckingAccount checkAccount = new CheckingAccount()
                                        {
                                            AccountID = new Guid("5734527e-b09c-4c5a-ab43-240d1d16f469"),
                                            CardID =  new Guid("5734527e-b09c-4c5a-ab43-240d1d16f469"),
                                            Balance = 10000,
                                            DayLimit = 10000,
                                        };
            bool isPrintRecept = false;
            bool expected = false;
            bool actual;
            actual = target.WithdrawMoney(amount, checkAccount, isPrintRecept);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        /// Test case 4
        /// </summary>
        [Test]
        public void TestWithdraw_LessThan50K_WithdrawFail()
        {
            ATMSystemBussiness target = new ATMSystemBussiness();
            float amount = 9000;
            CheckingAccount checkAccount = new CheckingAccount()
            {
                AccountID = new Guid("5734527e-b09c-4c5a-ab43-240d1d16f469"),
                CardID = new Guid("4f98e5d0-68f1-4702-8de2-4b0465e51949"),
                Balance = 10000,
                DayLimit = 10000,
            };
            bool isPrintRecept = false;
            bool expected = false;
            bool actual;
            actual = target.WithdrawMoney(amount, checkAccount, isPrintRecept);
            Assert.AreEqual(expected, actual);
        }
        /// <summary>
        /// Test case 5
        /// </summary>
        [Test]
        public void TestWithdraw_Is50KAndNotExistCard_WithdrawFail()
        {
            ATMSystemBussiness target = new ATMSystemBussiness();
            float amount = 50000;
            CheckingAccount checkAccount = new CheckingAccount()
            {
                AccountID = new Guid("5734527e-b09c-4c5a-ab43-240d1d16f469"),
                CardID = new Guid("4f98e5d0-68f1-4702-8de2-4b0465e51949"),
                Balance = 10000,
                DayLimit = 10000,
            };
            bool isPrintRecept = false;
            bool expected = false;
            bool actual;
            actual = target.WithdrawMoney(amount, checkAccount, isPrintRecept);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        /// Test case 6
        /// </summary>
        [Test]
        public void TestWithdraw_Is50KPrintRecept_WithdrawFail()
        {
            ATMSystemBussiness target = new ATMSystemBussiness();
            float amount = 50000;
            CheckingAccount checkAccount = new CheckingAccount()
            {
                AccountID = new Guid("5734527e-b09c-4c5a-ab43-240d1d16f469"),
                CardID = new Guid("4f98e5d0-68f1-4702-8de2-4b0465e51949"),
                Balance = 10000,
                DayLimit = 10000,
            };
            bool isPrintRecept = true;
            bool expected = false;
            bool actual;
            actual = target.WithdrawMoney(amount, checkAccount, isPrintRecept);
            Assert.AreEqual(expected, actual);
        }
        /// <summary>
        /// Test case 7
        /// </summary>
        [Test]
        public void TestWithdraw_Is50K_WithdrawSuccess()
        {
            ATMSystemBussiness target = new ATMSystemBussiness();
            float amount = 50000;
            CheckingAccount checkAccount = new CheckingAccount()
            {
                AccountID = new Guid("5734527e-b09c-4c5a-ab43-240d1d16f469"),
                CardID = new Guid("5734527e-b09c-4c5a-ab43-240d1d16f469"),
                Balance = 10000,
                DayLimit = 10000,
            };
            bool isPrintRecept = true;
            bool expected = true;
            bool actual;
            actual = target.WithdrawMoney(amount, checkAccount, isPrintRecept);
            Assert.AreEqual(expected, actual);
        }
    }
}
